package com.guet.main.controller;


import com.guet.common.utils.R;
import com.guet.main.entity.RoomKind;
import com.guet.main.service.RoomKindService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * kind 前端控制器
 * </p>
 *
 * @author csp
 * @since 2022-07-30
 */
@RestController
@RequestMapping("/main/room-kind")
@CrossOrigin
public class RoomKindController {
    @Autowired
    private RoomKindService roomKindService;

    @GetMapping("/list")
    @ApiOperation("获取所有会议室分类")
    public R list(){
        List<RoomKind> list = roomKindService.list(null);
        return R.ok().data("list",list);
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除")
    public R delete(@PathVariable String id){
        boolean b = roomKindService.removeById(id);
        return b?R.ok():R.error();
    }

    @GetMapping("/add/{kind}")
    @ApiOperation("增加分类")
    public R add(@PathVariable String kind){
        RoomKind roomKind = new RoomKind();
        roomKind.setKind(kind);
        boolean save = roomKindService.save(roomKind);
        return save?R.ok():R.error();
    }
}

